from django.db import models

# 面试岗位
class Station(models.Model):
    id = models.AutoField(verbose_name='id',primary_key=True)
    position = models.CharField(verbose_name='岗位名称', max_length=50, null=True)
    hcnumber = models.CharField(verbose_name='HC数量', max_length=50, null=True)
    base = models.CharField(verbose_name='base', max_length=200, null=True)
    level = models.CharField(verbose_name='级别', max_length=50, null=True)
    # position_state 开放 关闭
    position_state = models.CharField(verbose_name='岗位状态', max_length=50, null=True,default='开放')
    position_jd = models.TextField(verbose_name='岗位JD', null=True)
    service = models.CharField(verbose_name='服务商', max_length=50, null=True)
    priority = models.CharField(verbose_name='优先级', max_length=50, null=True)
    slt_position = models.CharField(verbose_name='是否补岗', max_length=50, null=True)
    opening_time = models.DateTimeField(verbose_name='开放时间', null=True)
    closing_time = models.DateTimeField(verbose_name='关闭时间', null=True)
    group_id = models.CharField(verbose_name='入流群', max_length=50,null=True)

# 面试官
class Interviewer(models.Model):
    name = models.CharField(verbose_name='面试官姓名', max_length=50, null=True)
    group = models.CharField(verbose_name='组别', max_length=50, null=True)
    hi_id = models.CharField(verbose_name='HI账号', max_length=50, null=True)
    baidu_email = models.CharField(verbose_name='百度邮箱', max_length=50, null=True)
    phone = models.CharField(verbose_name='手机号', max_length=50, null=True)
    position = models.ManyToManyField(Station,verbose_name='面试岗位面试官',related_name='interviewers')

class Engineer(models.Model):
    name = models.CharField(verbose_name='姓名', max_length=50, null=True)
    group = models.CharField(verbose_name='组别（服务商）', max_length=50, null=True)
    hi_id = models.CharField(verbose_name='HI账号', max_length=50, null=True)
    baidu_email = models.CharField(verbose_name='百度邮箱', max_length=50, null=True)
    phone = models.CharField(verbose_name='手机号', max_length=50, null=True)


class Manage(models.Model):
    name = models.CharField(verbose_name='姓名', max_length=50, null=True)
    group = models.CharField(verbose_name='组别', max_length=50, null=True)
    hi_id = models.CharField(verbose_name='HI账号', max_length=50, null=True)
    baidu_email = models.CharField(verbose_name='百度邮箱', max_length=50, null=True)
    phone = models.CharField(verbose_name='手机号', max_length=50, null=True)
    position = models.ManyToManyField(Station,verbose_name='岗位经理',related_name='manages')


# 简历
class JianLi(models.Model):
    position = models.ForeignKey(Station, verbose_name='岗位名称', on_delete=models.CASCADE, null=True, related_name='station')
    recommend_company = models.CharField(verbose_name='推荐公司', max_length=50, null=True)
    recommended_date = models.DateTimeField(verbose_name='推荐日期', null=True)
    name = models.CharField(verbose_name='姓名', max_length=50, null=True)
    age = models.CharField(verbose_name='年龄', max_length=50, null=True)
    gender = models.CharField(verbose_name='性别', max_length=50, null=True)
    education = models.CharField(verbose_name='学历', max_length=50, null=True)
    speciality = models.CharField(verbose_name='专业', max_length=50, null=True)
    is_xuexin = models.CharField(verbose_name='是否学信网可查', max_length=50, null=True)
    img_xuexin = models.TextField(verbose_name='学信网截图', null=True)
    years_of_service = models.CharField(verbose_name='工作年限', max_length=50, null=True)
    end_school = models.CharField(verbose_name='毕业时间', max_length=50, null=True)
    contact = models.CharField(verbose_name='联系方式', max_length=50, null=True)
    school = models.CharField(verbose_name='毕业院校', max_length=50, null=True)
    career_planning = models.CharField(verbose_name='职业规划', max_length=100, null=True)
    expected_location = models.CharField(verbose_name='期望工作地点', max_length=50, null=True)
    commute_distance = models.CharField(verbose_name='通勤距离', max_length=50, null=True)
    reason_for_leave = models.CharField(verbose_name='离职原因', max_length=50, null=True)
    frequency = models.CharField(verbose_name='工作更换频率', max_length=50, null=True)
    grading = models.CharField(verbose_name='服务商定级', max_length=50, null=True)
    capacity = models.TextField(verbose_name='技术能力', null=True)
    work_experience = models.TextField(verbose_name='工作经验', null=True)
    soft_qualities = models.CharField(verbose_name='软素质', max_length=100, null=True)
    overtime_acceptance_rate = models.CharField(verbose_name='加班接受度', max_length=100, null=True)
    willingness_and_attitude = models.CharField(verbose_name='态度意愿', max_length=100, null=True)
    on_duty_time = models.CharField(verbose_name='最快到岗时间', null=True,max_length=50)
    is_there_an_interview = models.CharField(verbose_name='是否有offer', max_length=50, null=True)
    other_situations = models.CharField(verbose_name='其他情况', max_length=50, null=True)
    textarea = models.TextField(verbose_name='综合评价', null=True)
    sound_recording = models.TextField(verbose_name='录音',  null=True)
    annex = models.TextField(verbose_name='附件',  null=True)
    personal_resume = models.TextField(verbose_name='个人简历', null=True)
    qa_file = models.TextField(verbose_name='面试qa', null=True)

# 面试状态
class ResumeStatus(models.Model):
    jianli = models.OneToOneField(JianLi, verbose_name='简历', on_delete=models.CASCADE, null=True,related_name='resume_status')
    # interview_status 空 一面 二面 三面 待录用审批 通过
    interview_status = models.CharField(verbose_name='面试状态', max_length=50, null=True,default='')
    grading = models.CharField(verbose_name='业务定级', max_length=50, null=True)
    iso_resume_re_time = models.DateTimeField(verbose_name='ISO复核时间', null=True)
    iso_resume_re_name = models.CharField(verbose_name='ISO复核人', null=True,max_length=50)
    resume_re_time = models.DateTimeField(verbose_name='简历复筛时间', null=True)
    resumer_re_name = models.CharField(verbose_name='简历复筛人', max_length=50, null=True)

    one_interviewer = models.CharField(verbose_name='一面面试官', max_length=50, null=True)
    one_side_time = models.DateTimeField(verbose_name='一面时间', null=True)
    one_side_reason = models.TextField(verbose_name='一面面评', null=True)

    two_interviewer = models.CharField(verbose_name='二面面试官', max_length=50, null=True)
    two_side_time = models.DateTimeField(verbose_name='二面时间',  null=True)
    two_side_reason = models.TextField(verbose_name='二面面评', max_length=200, null=True)

    three_interviewer = models.CharField(verbose_name='三面面试官', max_length=50, null=True)
    three_side_time = models.DateTimeField(verbose_name='三面时间', null=True)
    three_side_reason = models.TextField(verbose_name='三面面评', max_length=200, null=True)

    # 面评
    reason = models.CharField(verbose_name='面评/原因', max_length=200, null=True)
    interview_repulse = models.CharField(verbose_name='打回', max_length=50, null=True)
    interview_repulse_reason = models.CharField(verbose_name='打回原因', max_length=100, null=True)

    # 服务商给的
    note = models.CharField(verbose_name='备注', max_length=200, null=True,default='')
    interview_time = models.DateTimeField(verbose_name='面试日期', null=True)
    jianli_end_time = models.DateTimeField(verbose_name='最后结束时间', null=True)
    create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True, null=True)
    joined_or_not = models.CharField(verbose_name='是否入职', max_length=50, null=True)
    abandon_interview = models.CharField(verbose_name='放弃面试', max_length=50, null=True)
    entry_time = models.DateTimeField(verbose_name='入职时间', null=True)
    engineer_entry_time = models.DateTimeField(verbose_name='服务商预计入职时间', null=True)
    interview_progress = models.CharField(verbose_name='面试进展', max_length=50, null=True,default='待推送')
    interview_result = models.CharField(verbose_name='结果', max_length=50, null=True,default='')
    #0：待复核，1。5 待推送，1：已推送，2：不推送，3:待复筛 4：简历fail 5：待一面 6：一面fail
    # 7：一面通过 8：待二面 9：二面fail 10：面试通过 11:待入职 12:确认入职 13 服务商沟通offer
    interview_discontinue = models.CharField(verbose_name='中止面试', max_length=50, null=True)

    matching = models.TextField(verbose_name='ISO审核人岗匹配', null=True)
    approval = models.CharField(verbose_name='录用审批', max_length=50, null=True)
    approval_name = models.CharField(verbose_name='审批人', max_length=50,null=True)
    approval_time = models.DateTimeField(verbose_name='审批时间',null=True)


# 日志
class StationLog(models.Model):
    person = models.CharField(verbose_name='操作人', max_length=50, null=True)
    edit_time = models.DateTimeField(verbose_name='操作时间', auto_now_add=True,null=True)
    edit_title = models.TextField(verbose_name='操作字段', max_length=50, null=True)
    edit_before = models.TextField(verbose_name='修改前',null=True)
    edit_after = models.TextField(verbose_name='修改后',null=True)
    station_id = models.CharField(verbose_name='refer', max_length=50, null=True)